package com.example.jetpacktest.navigation

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.Navigation

import com.example.jetpacktest.R
import kotlinx.android.synthetic.main.fragment_fragment2.view.*


/**
 */
class Fragment2 : Fragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        var view = inflater.inflate(R.layout.fragment_fragment2, container, false)

//        常规接受参数
//        var bundle = arguments
//        var name = bundle?.getString("name")
//        var age = bundle?.getInt("age")
//        Log.e("!!!!!!!!!",name + age)


        //safe args 接收参数
        var username = Fragment1Args.fromBundle(arguments!!).username
        var userage = Fragment1Args.fromBundle(arguments!!).userage
        view?.textshow?.text = username + userage


        view?.btn_back?.setOnClickListener {
            Navigation.findNavController(it).popBackStack()
        }
        return view
    }

}
